package com.HospitalOutpatient.controller;



import com.HospitalOutpatient.exception.NotLoginException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {


    /**
     * token异常
     * @param ex
     * @return
     */
    @ExceptionHandler(NotLoginException.class)
    public Result doBusinessException(NotLoginException ex){
        return new Result(ex.getCode(), null, ex.getMessage());
    }


    /**
     * 未知异常
     * @param ex
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex){
        //记录日志
        //发送消息
        ex.printStackTrace();
        return new Result(Code.SYSTEM_UNKNOW_ERR,null,"系统繁忙,请稍后再试");

    }

}

